import {
	defineStore
} from 'pinia';
import {
	ajaxFun
} from "../untils/ajax.js";

import {getUserInfo} from "@/untils/getUserInfo.js";
import {getLocation} from "@/untils/getLocation.js"

export const useUserStore = defineStore('user', {
	state: () => ({
		location: {},
		userInfo: {} //存放数据信息
	}),
	actions: {

	  async	login() { //登录
		
		let {userInfo}=await getUserInfo();// 1.获取用户信息  
		 userInfo.userid=45;
		this.userInfo=userInfo;
		
		let {latitude,longitude}=await getLocation();// 当前位置
		console.log(latitude,longitude);
		this.location={
			latitude,
			longitude
		}
		
		uni.switchTab({
			url:"/pages/index/index"
		})
		
		},
	},
	unistorage: true
});